package com.inspector.app.util;

import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;

import com.hjq.toast.Toaster;

public class ToastUtil {

    private static ToastUtil toastUtil;
    public static ToastUtil getInstance() {
        if (toastUtil == null) {
            toastUtil = new ToastUtil();
        }
        return toastUtil;
    }

    private final Handler mHandler = new Handler(Looper.getMainLooper());
    public void showToast(final String msg) {
        if (TextUtils.isEmpty(msg)) return;
        if (Looper.myLooper() != Looper.getMainLooper()) {
            mHandler.post(() -> Toaster.show(msg));
            return;
        }

        Toaster.show(msg);
    }

}
